﻿@inject IEventService _eventService

@if (!string.IsNullOrWhiteSpace(Model.Link))
{
    <MChip Small Color="primary" Outlined OnClick="@(()=>_eventService.OpenNewPage(GetLink()))" Class=" ma-1">
        <MIcon Left Small>@IconType.Link.ToIconString()</MIcon>
        @GetLink()
    </MChip>
}

@code {
    [Parameter]
    public GameReleaseViewModel Model { get; set; }

    public string GetLink()
    {
        if(string.IsNullOrWhiteSpace(Model.Link))
        {
            return null;
        }
        return Model.PublishPlatformType switch
        {
            PublishPlatformType.Steam => "https://store.steampowered.com/app/" + Model.Link,
            _ => ""
        };
    }
}
